package com.etime.shyauth.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.etime.shyauth.dto.SysRoleRightDto;
import com.etime.shyauth.dto.SysUserRoleDto;
import com.etime.shyauth.pojo.SysUserRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 用户角色管理dao层
 */
@Repository
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {

    /**
     * 查询用户角色列表（用于初始化用户角色分配）
     * @param userid 用户id
     * @return 用户角色列表；urid=null表示该用户没有此角色
     */
    @Select("select a.roleid,rolename,b.urid " +
            " from sysrole a left outer join sysuserrole b on a.roleid=b.roleid " +
            " and b.userid=#{userid}" +
            " where rolestate=1")
    List<SysUserRoleDto> selectSysUserRoleList(@Param("userid") int userid);
}
